﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Entidades;

namespace CapaPresentacion.Controles
{
    /// <summary>
    /// Interaction logic for LabelAndCombo.xaml
    /// </summary>
    public partial class LabelAndCombo : UserControl
    {

        public static readonly DependencyProperty FuenteDatosProperty = DependencyProperty.Register("FuenteDatos", typeof(List<ViewEntity>), typeof(LabelAndCombo));
        public static readonly DependencyProperty ValorSeleccionadoProperty = DependencyProperty.Register("ValorSeleccionado", typeof(string), typeof(LabelAndCombo));
        public static readonly DependencyProperty HabilitadoProperty = DependencyProperty.Register("Habilitado", typeof(bool), typeof(LabelAndCombo));


        public LabelAndCombo()
        {
            InitializeComponent();


            Binding b1 = new Binding();
            b1.Source = this;
            b1.Path = new PropertyPath(LabelAndCombo.FuenteDatosProperty);
            b1.Mode = BindingMode.TwoWay;
            this.cmb.SetBinding(ComboBox.ItemsSourceProperty, b1);

            Binding b2 = new Binding();
            b2.Source = this;
            b2.Path = new PropertyPath(LabelAndCombo.ValorSeleccionadoProperty);
            b2.Mode = BindingMode.TwoWay;
            this.cmb.SetBinding(ComboBox.SelectedValueProperty, b2);

            Binding b3 = new Binding();
            b3.Source = this;
            b3.Path = new PropertyPath(LabelAndCombo.HabilitadoProperty);
            b3.Mode = BindingMode.TwoWay;
            this.cmb.SetBinding(ComboBox.IsEnabledProperty, b3);


            this.cmb.DisplayMemberPath = "Descripcion";
            this.cmb.SelectedValuePath = "Id";
            this.cmb.IsEnabled = true;
        }

        public string Etiqueta
        {
            get { return lbl.Content.ToString(); }

            set { lbl.Content = value; }
        }


        public bool Habilitado
        {
            get { return (bool)this.GetValue(HabilitadoProperty); }

            set { this.SetValue(HabilitadoProperty, value); }
        }

        public string ValorSeleccionado
        {
            get 
            {
                return (String)this.GetValue(ValorSeleccionadoProperty);
            }

            set
            {
                this.SetValue(ValorSeleccionadoProperty, value);
            }
        }


        public List<ViewEntity> FuenteDatos
        {
            get
            {
                return (List<ViewEntity>)this.GetValue(FuenteDatosProperty);
            }

            set { SetValue(FuenteDatosProperty, value); }

        }


        public  Style Estilo
        {
           
            set
            {
                cmb.Style = value;
            }
        }




    }
}
